//
//  AppDelegate.m
//  MallManage_IOS
//
//  Created by 张浩 on 2023/9/11.
//

#import "AppDelegate.h"
#import "MM_PreLoadVC.h"
#import "MM_LoginVC.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

+ (AppDelegate *)appDelegate {
    return (AppDelegate *)[UIApplication sharedApplication].delegate;
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
//    self.window.backgroundColor = [UIColor redColor];

    [self setupRootViewController];
    
    [self setupReachability];
    
    [self.window makeKeyAndVisible];
    
    [MMNotificationCenter addObserver:self selector:@selector(logOutClick) name:MM_LogOutSuccessfully object:nil];
    
    return YES;
}

- (void)setupRootViewController {
    
    MM_PreLoadVC *preLoad = [[MM_PreLoadVC alloc] init];
    self.window.rootViewController = preLoad;
}

- (void)logOutClick {
    
    MM_LoginVC *loginVC = [[MM_LoginVC alloc] init];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:loginVC];
    self.window.rootViewController = nav;
}

- (void)setupReachability {
    
    [[AFNetworkReachabilityManager sharedManager] startMonitoring];
    //监听改变
    [[AFNetworkReachabilityManager sharedManager] setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        self.isReachable = [AFNetworkReachabilityManager sharedManager].reachable;
    }];
}

#pragma mark - UISceneSession lifecycle


-(void)applicationWillResignActive:(UIApplication *)application{
    NSLog(@"applicationWillResignActive");
}

- (void)applicationDidBecomeActive:(UIApplication *)application{
    NSLog(@"applicationDidBecomeActive");
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    NSLog(@"applicationWillEnterForeground");
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    NSLog(@"applicationDidEnterBackground");
}

@end
